/**----------------------------------------
 * @description 字符串工具类
 * @author      lxc
 * @file        StringTool.ts
 * @Date        2022-05-05
 * @version     1.0.0
 * ----------------------------------------
 */

export class StringTool {
    /**
     * 格式化秒数时间为 xx:xx
     * @param second 
     * @returns 
     */
    formatTime(second: number): string {
        let format = ""
        let minuteNum = Math.floor(second / 60)
        let secondNum = Math.floor(second % 60)
        if(minuteNum > 9){
            if(secondNum > 9){
                format = `${minuteNum}:${secondNum}`
            }else{
                format = `${minuteNum}:0${secondNum}`
            }
        }else{
            if(secondNum > 9){
                format = `0${minuteNum}:${secondNum}`
            }else{
                format = `0${minuteNum}:0${secondNum}`
            }
        }
        return format
    }
}